package com.example.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class LoggingAspect {


    @AfterReturning(pointcut = "execution(* com.example.service..*(..))", returning = "result")
    public void logAfter(JoinPoint joinPoint, Object result) {
        log.info("方法 {} 执行成功，返回结果：{}", joinPoint.getSignature().getName(), result);
    }

    @AfterReturning(pointcut = "execution(* com.example.service..*(..))", returning = "result")
    public void logAfterReturning(JoinPoint joinPoint, Object result) {
        log.info("方法 {} 执行成功，返回结果：{}", joinPoint.getSignature().getName(), result);
    }
}
